<template>
  <div class="dashboard-container">
    <component :is="dynamicComponent" v-bind="$attrs" v-on="$listeners" />
  </div>
</template>

<script>
import store from '../../store';
export default {
  name: 'SyncPage',
  props: {
    page: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      dynamicComponent: ''
    }
  },
  mounted() {
    this.init();
  },
  methods: {
    async init() {
      const module = {};
      module[this.page.code] = 'http://localhost:11000/plugin/' + this.page.url;
      console.log(module);
      // 加载模块
      await this.$moduleLoader(module);
      // TODO:
      this.dynamicComponent = store.state.dynamicComponent.GLOBAL[this.page.code];
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
